package com.bainuo.doctor.common.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.TextView;

import com.bainuo.doctor.common.R;


/**
 * Description:基础loading view
 * Created by MonkeyShen on 2017/1/16.
 * Mail:shenminjie92@sina.com
 */

public class LoadingDialog extends Dialog {

    private LoadingDialog mLoadingDialog;
    private TextView mTvTip;
    private String mStrtip;

    public LoadingDialog(Context context) {
        super(context, R.style.DialogStyle);
    }

//    public LoadingDialog(Context context, int theme) {
//        super(context, R.style.DialogStyle);
//    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_dialog);
        getWindow().getAttributes().gravity = Gravity.CENTER;
        ImageView imageView = (ImageView) findViewById(R.id.imageView1);
        mTvTip = (TextView) findViewById(R.id.loading_tv);
        mTvTip.setText(mStrtip);
        imageView.setImageResource(R.drawable.load_anim);
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
        animationDrawable.start();
    }


    public void show(String string) {
        mStrtip = string;
        if(mTvTip != null)
            mTvTip.setText(mStrtip);
        super.show();
    }

    @Override
    public void show() {
        show("正在加载");
    }
}
